import rxAjax from '@/assets/js/ajax.js';

export const OsGroupMenuApi = {};

OsGroupMenuApi.baseUrl= '/api-user/user/org/osGroupMenu';
OsGroupMenuApi.exportUrl= OsGroupMenuApi.baseUrl + '/listExport';

OsGroupMenuApi.findMenuListByGroupId= function(parameter) {
  var url=OsGroupMenuApi.baseUrl + '/findMenuListByGroupId';
  return rxAjax.get(url,parameter);
}

OsGroupMenuApi.getOsGroupMenuList= function(parameter) {
  var url=OsGroupMenuApi.baseUrl + '/query';
  return rxAjax.postJson(url,parameter).then(res =>{
    return res.result
  })
}

OsGroupMenuApi.getAllOsGroupMenuList= function(parameter) {
  var url=OsGroupMenuApi.baseUrl + '/getAll';
  return rxAjax.get(url,parameter).then(res =>{
    return res.data
  })
}

OsGroupMenuApi.saveOsGroupMenu= function(menuList,groupId,groupContainsSub, dimId) {
  var url=OsGroupMenuApi.baseUrl + '/saveOrUpdate?groupId=' +groupId;
    if(groupContainsSub){
        url+="&groupContainsSub="+groupContainsSub;
    }
    if(dimId){
        url+="&dimId="+dimId;
    }
  return rxAjax.postJson(url,menuList);
}

OsGroupMenuApi.delOsGroupMenu= function(parameter) {
  var url=OsGroupMenuApi.baseUrl + '/del';
  return rxAjax.postUrl(url,parameter);
}

OsGroupMenuApi.findContainsSub= function(parameter) {
    var url=OsGroupMenuApi.baseUrl + '/findContainsSub';
    return rxAjax.get(url,parameter);
}

export  default OsGroupMenuApi;
